//
//  YZXHomeButton.swift
//  YZXWeibo
//
//  Created by 叶周翔 on 16/7/23.
//  Copyright © 2016年 叶周翔. All rights reserved.
//

import UIKit

class YZXHomeButton: UIButton {
    
     init(title:String){
        
        super.init(frame: CGRectZero)
        self.setTitle(title, forState: UIControlState.Normal)
        self.setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal)
        self.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        
        // 自动适应
        self.sizeToFit()
    }
    
    
    override func layoutSubviews() {
        //一定要调用父类的方法
        super.layoutSubviews()
        self.titleLabel?.frame.origin.x = 0
        self.titleLabel?.font = UIFont.systemFontOfSize(15)
        self.imageView?.frame.origin.x = self.titleLabel!.frame.width + 4
        
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}